<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
		<title>APP</title>
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../css/header.css"/>
		<link rel="stylesheet" type="text/css" href="../css/selflist.css"/>
		<link rel="stylesheet" type="text/css" href="../css/jquery.mobile.min.css"/>
		<link rel="stylesheet" type="text/css" href="../css/dragdealer.css"/>
		<script type="text/javascript" src="../script/jquery-2.1.3.js"></script>
		<script type="text/javascript" src="../script/jquery.mobile-1.4.5.min.js"></script>
		<script type="text/javascript" src="../script/av-0.5.0.min.js"></script>
		<script type="text/javascript" src="../script/config.js"></script>
		<script type="text/javascript" src="../script/api.js"></script>
		<script type="text/javascript" src="../script/mico-bind-0.1.js"></script>
		<script type="text/javascript" src="../script/mico-user-0.1.js"></script>
		<script type="text/javascript" src="../script/usermanage.js"></script>
		<script type="text/javascript" src="../script/micokitmanage.js"></script>
		<script type="text/javascript" src="../script/mqttsev.js"></script>
		<script type="text/javascript" src="../script/devdic.js"></script>
		<script type="text/javascript" src="../script/msgdic-zh.js"></script>
		<script type="text/javascript" src="../script/dragdealer.js"></script>
		<script type="text/javascript" src="../script/jquery.md5.js"></script>
		<style>
			.micocontent {
				margin-top: 43px;
				background-color: #18161d;
				text-shadow: none;
			}
			/*专门用户管理*/
			.myselfcontent {
				margin-top: 43px;
				/*background-color: #31304a;*/
				background-color: #18161d;
				text-shadow: none;
			}
			.myselfcontented {
				margin-top: 46px;
				background-color: #18161d;
				text-shadow: none;
				border-bottom: 7px #18161d solid;
			}
			#tomyself {
				display: block;
			}
			#backleft {
				display: none;
			}
			#motorbtn {
				height: 25px;
				width: 49px;
			}
			#vmotorbtn {
				height: 25px;
				width: 49px;
			}
			#tohomepage {
				display: none;
			}
			.serachText {
				color: #24c5c1;
				margin: 0 auto;
			}
			.serachText span {
				color: #24c5c1;
				font-family: arial;
				font-size: 13px;
			}
			.serachText img {
				height: 8px;
				width: 8px;
			}
			#wifi_ssid::-webkit-input-placeholder {
				color: #120f16;
			}
			#wifi_psw::-webkit-input-placeholder {
				color: #120f16;
			}
			#wifi_ssid:-moz-placeholder {
				color: #120f16;
			}
			#wifi_psw:-moz-placeholder {
				color: #120f16;
			}
			.p img {
				width: 75px;
				margin-top: 17.5px;
			}
			.p {
				text-align: center;
			}
			.serachText2 {
				color: #24c5c1;
				/*margin: 0 auto;*/
				text-align: center;
			}
			.serachText2 span {
				color: #24c5c1;
				font-family: arial;
				font-size: 13px;
			}
			.serachText2 img {
				height: 8px;
				width: 8px;
			}
			#dev_psw::-webkit-input-placeholder {
				color: #120f16;
			}
			#dev_psw:-moz-placeholder {
				color: #120f16;
			}
			.lcop {
				color: #00EEEE;
				margin-right: 16px;
				float: right;
				font-size: 15px;
				font-family: arial;
			}
			#rgbonoffbtn {
				position: absolute;
				height: 80px;
				width: 80px;
				z-index: 999;
			}
			.BrightnessRight {
				margin-right: 34px;
				float: right;
			}
			.BrightnessLeft {
				margin-left: 325px;
				position: inherit;
				margin-top: -20px;
				float: left;
			}
			.easysearchcls {
				display: block;
				width: 100%;
			}
			.stopacls {
				display: block;
				width: 100%;
			}
			#stopelbtn {
				margin-top: 0px;
				background-image: url();
				background-color: #EFEFEF;
				border-radius: 0px;
			}
			#stopelbtn a span {
				color: #105284;
			}
			#authuserlist{
				margin-top: 41px;
			}
			#savefd{
				margin-top: 19px;
			}
		</style>
	</head>
	<body>
		<!--顶部标题-->
		<header id="header" class="header">
			<a class="left" onclick="checkpage()" id="backleft"><img src="../image/smallicon-2.png" alt=""/></a>
			<a class="left" id="tomyself"><img src="../image/smallicon-3.png" alt=""/></a>
			<span class="center" id="titleName">MiCOKit</span>
			<a class="right" id="toeasylink"><img src="../image/smallicon-4.png" alt=""/></a>
			<a class="right" id="tohomepage"><img src="../image/smallicon-3r.png" alt=""/></a>
		</header>
		<!--设备详情-->
		<div class="micocontent" data-role="page" id="homePage">
			<div data-role="content" align="center">
				<p id="devlistlodingid">
					<a href="#aboutPage" data-transition="none">加载设备...</a>
				</p>
				<p id="devlistshowid">
					<img src="../image/device_refresh.png" alt=""/>
				</p>
			</div>
		</div>
		<!--虚拟测试页面-->
		<div class="micocontent" data-role="page" id="virtualdev">
			<div class="devctrlrowed">
				<ul>
					<li class="devctrlrowed devinfoclsed">
						<div align="center">
							<a href="#" id="vchatliid"><img src="../image/uart.png" class="UartTU"/></a>
							<a href="#" id="vrgbliid"><img src="../image/RGB.png" class="RGBTU"/></a>
						</div>
					</li>
				</ul>
			</div>
			<!--<div class="devctrlrow">
			<ul>
			<li id="vchatliid" class="devctrlrow devinfocls">
			<a href="#" id="vtoUARTMSG"><img src="../image/icon4.png"><span>Uart</span><img class="rightarr" src="../image/rightarr.png"></a>
			</li>
			<li id="vrgbliid" class="devctrlrow devinfocls">
			<a href="#" id="vtorgbctrl"><img src="../image/icon5.png"><span>RGB</span><img class="rightarr" src="../image/rightarr.png"></a>
			</li>
			</ul>
			</div>-->
			<div class="devctrlrow">
				<div class="devinfotitle" id="vdevdataid">
					<span>设备数据</span>
				</div>
				<ul>
					<li id="vadcclsid" class="devctrlrow devinfocls">
						<img src="../image/light.png"/>
						<span>Light</span>
						<div class="devdetail" id="vadcid">
							1066
						</div>
					</li>
					<li id="vtempclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-temperature-120.png"/>
						<span>Temperature</span>
						<div class="devdetail" id="vtempid">
							28°C
						</div>
					</li>
					<li id="vhumiclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-water-120.png"/>
						<span>Humidity</span>
						<div class="devdetail" id="vhumiid">
							36%RH
						</div>
					</li>
					<li id="vpro_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-wifi-120.png"/>
						<span>Proximity</span>
						<div class="devdetail" id="vpro_sensorid">
							988
						</div>
					</li>
					<li id="vatmo_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-qiya-120.png"/>
						<span>Atmosphere</span>
						<div class="devdetail" id="vatmo_sensorid">
							999
						</div>
					</li>
					<li id="vmontion_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/motion.png"/>
						<span>Motion</span>
						<div class="devdetail" id="vmontion_sensorid">
							35
						</div>
					</li>
					<li id="vinfraedclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-hongwai-120.png"/>
						<span>Infrared</span>
						<div class="devdetail" id="vinfraedid">
							4035
						</div>
					</li>
					<li id="vmotor_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-dinaji-120.png"/>
						<span>Motor</span>
						<img class="rightarr" id="vmotorbtn" src="../image/smallicon-8kaiguan.png"/>
					</li>
				</ul>
			</div>
		</div>
		<!--真实设备详情页面-->
		<div class="micocontent" data-role="page" id="deviceinfo">
			<div class="devctrlrowed">
				<ul>
					<li class="devctrlrowed devinfoclsed">
						<div align="center">
							<a href="#" id="chatliid"><img src="../image/uart.png" class="UartTU"/></a>
							<a href="#" id="rgbliid"><img src="../image/RGB.png" class="RGBTU"/></a>
						</div>
					</li>
				</ul>
				<!--<ul>
				<li id="chatliid" class="devctrlrowed devinfoclsed">
				<a href="#" id="toUARTMSG"><img src="../image/uart.png" /></a>
				</li>
				<li id="rgbliid" class="devctrlrow devinfocls">
				<a href="#" id="torgbctrl"><img src="../image/RGB.png" /></a>
				</li>
				</ul>-->
			</div>
			<div class="devctrlrow">
				<div class="devinfotitle" id="devdataid">
					<span>设备数据</span>
				</div>
				<ul>
					<li id="adcclsid" class="devctrlrow devinfocls">
						<img src="../image/light.png"/>
						<span>Light</span>
						<div class="devdetail" id="adcid">
							NaN
						</div>
					</li>
					<li id="tempclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-temperature-120.png"/>
						<span>Temperature</span>
						<div class="devdetail" id="tempid">
							NaN
						</div>
					</li>
					<li id="humiclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-water-120.png"/>
						<span>Humidity</span>
						<div class="devdetail" id="humiid">
							NaN
						</div>
					</li>
					<li id="pro_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-wifi-120.png"/>
						<span>Proximity</span>
						<div class="devdetail" id="pro_sensorid">
							NaN
						</div>
					</li>
					<li id="atmo_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-qiya-120.png"/>
						<span>Atmosphere</span>
						<div class="devdetail" id="atmo_sensorid">
							NaN
						</div>
					</li>
					<li id="montion_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/motion.png"/>
						<span>Motion</span>
						<div class="devdetail" id="montion_sensorid">
							NaN
						</div>
					</li>
					<li id="infraedclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-hongwai-120.png"/>
						<span>Infrared</span>
						<div class="devdetail" id="infraedid">
							NaN
						</div>
					</li>
					<li id="motor_sensorclsid" class="devctrlrow devinfocls">
						<img src="../image/04devicename-dinaji-120.png"/>
						<span>Motor</span>
						<img class="rightarr" id="motorbtn" src="../image/smallicon-8kaiguan.png"/>
					</li>
				</ul>
			</div>
		</div>
		<!--RGB控制-->
		<div class="micocontent" data-role="page" id="rgbctrl">
			<!--<div class="onoffbtn">
			<select id="rgbonoffbtn" data-role="slider" onchange="checkrgbbtn()">
			<option>Off</option>
			<option>On</option>
			</select>
			</div>-->
			<img id="rgbonoffbtn" src="../image/switchon.svg"/>
			<div data-role="content" class="canvascls" align="center">
				<canvas id="colorPicker1"></canvas>
				<br/>
				<span class="colorspancls">亮度</span>
				<div id="brightslider" class="dragdealer">
					<!--<img class="BrightnessRight" src="../image/RGB-Brightness01-01.svg"/>-->
					<div class="handle red-bar">
						<span class="brightval" id="brightspanid"></span>
					</div>
					<!--<img class="BrightnessLeft" src="../image/RGB-Brightness02-01.svg" style="margin-left:315px;">-->
				</div>
				<span class="colorspancls">饱和度</span>
				<div id="satslider" class="dragdealer">
					<!--<img class="BrightnessRight" src="../image/RGB-Saturation01-01.svg"/>-->
					<div class="handle red-bar">
						<span class="satval" id="satspanid">
					</div>
					<!--<img class="BrightnessLeft" src="../image/RGB-Saturation02-01.svg" style="margin-top:-40px;"></span>-->
				</div>
			</div>
		</div>
		<!--聊天列表-->
		<div class="micocontent" data-role="page" id="chatlist">
			<div data-role="content" align="center">
				<ul id="chatmsg"></ul>
			</div>
		</div>
		<!--SSID配置-->
		<div class="micocontent" data-role="page" id="ssidmanage">
			<div class="content">
				<div class="serachText">
					<img src="../image/06connect-circle15.svg"/>&nbsp; <span>请将设备进行配网</span>
				</div>
				<div class="phoned">
					<input type="text" data-theme="f" data-role="none" placeholder="WiFi名称" id="wifi_ssid" readonly/>
				</div>
				<div class="pswed">
					<input type="text" data-theme="f" data-role="none"  placeholder="WiFi密码" id="wifi_psw" onblur="onblurmDNS()" onfocus="onfocusmDNS()"/>
				</div>
				<div class="subbutton" onclick="getdevip()" id="sousuoid">
					<span><a class="easysearchcls" href="#" data-rel="popup" data-position-to="window" data-transition="none" data-dismissible="false">搜索 </a></span>
				</div>
			</div>
			<div class="mdnsdevlistcls">
				<ul class="mdnsdjhsb">
					待绑定设备
				</ul>
				<ul id="mdnsdevliid">
					<!--<li class="mdnsdevcls" onclick="ajaxgetdveid('adasdasdas')"><a><img src="../image/weijihuo.png"/><div><p class="mdnsdjhsbname">MK3288</p><p class="mdnsdjhsbip">192.168.1.23()</p></div></a></li>-->
				</ul>
			</div>
		</div>
		<!--EasyLink密码配置-->
		<div class="micocontent" data-role="page" id="devmanage">
			<div class="content">
				<div class="p">
					<img src="../image/icon1-120.png"/>
				</div>
				<div class="serachText2">
					<img src="../image/06connect-circle15.svg"/>&nbsp; <span>配网成功.请设置设备密码</span>
				</div>
				<div class="phoned">
					<input type="text" data-theme="f" data-role="none" placeholder="请输入四位设备密码" id="dev_psw"/>
				</div>
				<!--<div class="psw">
				<input type="password" data-theme="f" data-role="none" placeholder="Password Confirmation" id="dev_psw_conf"/>
				</div>-->
				<div class="subbutton" onclick="ajaxgetdveid()">
					<span><a href="#">确定</a></span>
				</div>
				<!--<div class="savetipscls" align="center">
				<<<<<<< .mine
				<span>设备密码请输入4位数字。</span>
				=======
				<span>设备需要重启，请5秒后再点击保存。</span>
				>>>>>>> .r11
				</div>-->
			</div>
		</div>
		<!--用户管理界面-->
		<div class="myselfcontent" data-role="page" id="myselfpage">
			<div class="myselfrow" id="userrowid">
				<div class="myselflisttitle" align="center" id="toeditaccount">
					<img class="rightarr" src="../image/touxiang.png"/>
					<br/>
					<span id="mynickname">NickName</span>
				</div>
				<ul>
					<li class="myselfrow myselflistcls" >
						<div>
							<a href="#" id="toAuthpage"><img src="../image/03my account-Authorize70.svg"/><span class="lvzi">授权管理</span></a><a href="#" id="tofbpage"><img src="../image/03my account-feedback70.svg"/><span class="lanzi">我要反馈</span></a>
						</div>
					</li>
					<li class="myselfrow myselflistcls" >
						<div>
							<a href="#" id="touphispage"><img src="../image/03my account-update70.svg"/><span class="lanzi">更新日志</span></a><a href="#"><img src="../image/03my account-guide70.svg"/><span class="lvzi">关于我们</span></a>
						</div>
					</li>
					<!--<!--<li class="myselfrow myselflistcls" id="logout">
					<!--<a href="#"><img src="../image/smallicon-dengchu.png"/><span>退出</span></a>-->
					<!--</li>-->
					<!--<li class="myselfrow myselflistcls">
						<div>
							<a href="#" id=""><img src="../image/03my account-about70.svg"/><span class="lvzi">关于我们</span></a><a href="#"><img src="../image/03my account-more70-01.svg"/><span class="lanzi">更多</span></a>
						</div>
					</li>-->
				</ul>
			</div>
		</div>
		<!--反馈信息-->
		<div class="micocontent" data-role="page" data-theme="f" id="feedbackpage">
			<div class="fdcontent">
				<textarea rows="10" id="fdcontent" class="fdcontentcls"></textarea>
				<div class="subbutton" id="savefd">
					<span><a href="#">提交反馈</a></span>
				</div>
			</div>
		</div>
		<!--更新日志-->
		<div class="micocontent" data-role="page" data-theme="f" id="uphispage">
			<div class="fdcontent" align="left" id="uphistextid"></div>
		</div>
		<!--设备授权-->
		<div class="micocontent" data-role="page" id="authpage">
			<div data-role="content" align="center">
				<p id="devAuthlodingid">
					<a href="#aboutPage" data-transition="none">加载设备...</a>
				</p>
				<p id="devAuthshowid">
					<img src="../image/device_refresh.png" alt=""/>
				</p>
			</div>
		</div>
		<!--用户信息管理-->
		<div class="myselfcontented" data-role="page" id="editaccount">
			<div class="myselfrowed">
				<ul>
					<li class="myselfrowedp"></li>
					<li class="myselfrowed myselflistclsed" id="nickclsid">
						<img class="pitu"  src="../image/03my account-gender45.svg"/><span class="fontcolor">昵称</span>
						<div class="lcop" id="nicknameid">
							未登录
						</div>
					</li>
					<li class="myselfrowed myselflistclsed" id="emailclsid">
						<img class="pitu"  src="../image/03my account-email45.svg"/><span class="fontcolor">Email</span>
						<div class="lcop" id="emailid">
							未设置
						</div>
					</li>
					<li class="myselfrowedp"></li>
					<li class="myselfrowed myselflistclsed" id="pswclsid">
						<img class="pitu"  src="../image/03my account-key45.svg"/><span class="fontcolor">修改密码</span>
					</li>
					<li class="bk"></li>
					<li class="banked" id="logout">
						<a href="#"><span class="bank">退出登录</span></a>
					</li>
				</ul>
			</div>
		</div>
		<!--绑定用户列表-->
		<div class="micocontent" data-role="page" id="authuserlist">
			<div class="authlistcls" id="authlistid">
				<!--<ul>
					<li class="mdnsdevcls">
						<a>
							<img src="../image/userquery1.png"/>
							<div class="aunamecls"><p style="color:#24c5c1">MK3288</p></div>
							<img class="authctrlcls" src="../image/authdelete.svg"/>
						</a>
					</li>
				</ul>
				<ul>
					<li class="mdnsdevcls">
						<a>
							<img src="../image/userquery2.png"/>
							<div class="aunamecls"><p style="color:#882ab4">MK3288</p></div>
							<img class="authctrlcls" src="../image/authdelete.svg"/>
						</a>
					</li>
				</ul>-->
			</div>
			<div class="authaddcls" id="authaddid">
				<ul>
					<li>
						<img src="../image/authadd.svg"/>
						<span>添加新用户</span>
					</li>
				</ul>
			</div>
		</div>
		<!--隐藏标识项-->
		<input type="hidden" id="devidtopic" value=""/>
	</body>
	<script type="text/javascript" src="../script/colorPicker.js"></script>
	<script type="text/javascript">
		//		给pop加载的时候用
//		var $jqelpop = $('<div data-role="popup" id="popupeasy" data-overlay-theme="b" data-dismissible="false" >' 
//		+ '<img style="width:250px;" src="../image/easylink.gif"/>' + '<div class="subbutton" id="stopelbtn">' 
//		+ '<a class="stopacls" data-rel="back"><span>结束配网</span></a>' + '</div>' + '</div>');
//		$jqelpop.appendTo($("#sousuoid")).popup();
		var strDM;
		apiready = function() {
			api.removeLaunchView();
			var header = $api.byId('header');
			$api.fixIos7Bar(header);
			strDM = api.systemType;
			if (strDM == 'ios') {
				$(".header").css("padding-top", "30px");
				$(".left").css("top", "32px");
				//				$(".center").css("top", "25px");
				$(".right").css("top", "32px");
				$(".micocontent").css("margin-top", "60px");
				$(".myselfcontent").css("margin-top", "60px");
				$(".myselfcontented").css("margin-top", "61px");
				listy = 67;
			}
			//临时应付小米2s的BUG
			if(api.systemVersion < "4.4"){
				$(".header").css("position", "absolute");
			}
			getUserToken();
			devicelist_getDevList();
			if (strDM != 'ios') {
				listy = 56;
				api.addEventListener({
					name : "keyback"
				}, function(ret, err) {
					checkpage();
				});
			}
			addTouchMove();
		};

		function getUserToken() {
			userToken = getUserInfo().get("userToken");
		}

		//	前往EasyLink页面
		$("#toeasylink").click(function() {
			changpage("ssidmanage", "EasyLink");
			//关闭listview
			devlistobj.close();
			PAGETAG = 5;
			//获取ssid
			getWifiSsid();
			getmDNSlist();
		});
		//设备列表刷新
		$("#devlistshowid").click(function() {
			showRefreshImg(1);
			devicelist_getDevList();
		});
		//授权设备刷新
		$("#devAuthshowid").click(function() {
			showAuthRefreshImg(1);
			devicelist_getAuthDev();
		});
		//		前往rgb页面
		$("#rgbliid").click(function() {
			//		$("#torgbctrl").click(function() {
			//rgbreadtag = 0;
			changpage("rgbctrl", "");
			if ("../image/switchon.svg" == $("#rgbonoffbtn").attr("src")) {
				ctrlrgb();
			}
			sliderctrl();
			PAGETAG = 3;
			addTouchMove();
			//	删除定时publish
			window.clearInterval(selfInterval);
		});
		//		前往chat页面
		$("#chatliid").click(function() {
			//		$("#toUARTMSG").click(function() {
			changpage("chatctrl", "");
			chatctrl();
			//			ctrlrgb();
			//			sliderctrl();
			PAGETAG = 4;
			//	删除定时publish
			window.clearInterval(selfInterval);
		});
		//		前往feedback页面
		$("#tofbpage").click(function() {
			changpage("feedbackpage", "反馈");
			PAGETAG = 7;
		});
		//前往用户信息修改界面
		$("#toeditaccount").click(function() {
			//页面跳转
			changpage("editaccount", "账号管理");
			PAGETAG = 7;
		});
		//		前往Update页面
		$("#touphispage").click(function() {
			changpage("uphispage", "更新日志");
			var showid = $("#uphistextid");
			readHisFile("uphis.txt", showid);
			PAGETAG = 7;
		});
		//		前往authorize页面
		$("#toAuthpage").click(function() {
			changpage("authpage", "授权管理");
			PAGETAG = 8;
			devicelist_getAuthDev();
		});
		//前往用户管理
		$("#tomyself").click(function() {
			changpage("myselfpage", "");
			//纯色
			devlistobj.close();
			PAGETAG = 6;
		});
		//前往首页
		$("#tohomepage").click(function() {
			//页面跳转
			changpage("homePage", "MiCOKit");
			//	刷新内容
			devicelist_getDevList();
		});
		//停止EasyLink
		$("#stopelbtn").click(function() {
			stopEasyLink();
			PAGETAG = 5;
		});
		//rgb开关
		$("#rgbonoffbtn").click(function() {
			var btnsrc = $("#rgbonoffbtn").attr("src");
			if ("../image/switchon.svg" == btnsrc) {
				$("#rgbonoffbtn").attr("src", "../image/switchoff.svg");
				window.clearInterval(rgbctrlinterval);
				dealwithrgbbtn(false);
			} else {
				$("#rgbonoffbtn").attr("src", "../image/switchon.svg");
				dealwithrgbbtn(true);
				ctrlrgb();
			}
		});
		//电动机控制
		$("#motorbtn").click(function() {
			var mtbtn = $("#motorbtn");
			var uartcode;
			if (mtbtn.attr("src") == "../image/smallicon-9kaiguan.png") {
				mtbtn.attr("src", "../image/smallicon-8kaiguan.png");
				uartcode = '{"' + MOTOR_KEY + '":0}';
				micoPublish(DEVID_GLOBAL + "/in/write/" + app1, uartcode);
			} else {
				mtbtn.attr("src", "../image/smallicon-9kaiguan.png");
				uartcode = '{"' + MOTOR_KEY + '":1}';
				micoPublish(DEVID_GLOBAL + "/in/write/" + app1, uartcode);
			}
		});
		
		//添加新用户
		$("#authaddid").click(function(){
			addNewUser();
		});
	</script>
	<!--以下是画圆圈的-->
	<script type="text/javascript" src="../script/colorPicker.js"></script>
	<script>
		//亮度和饱和度
		var bsliderMask;
		var ssliderMask;
		//是否开灯
		//		var rgb_switch;rgb_hues
		var width = 0.69 * document.body.clientWidth;
		//		var width = 0.4 * document.body.clientHeight;
		//按钮的高度,手机会有少许偏移，所以设成上移3个px
		var switchbttop = width / 2 - 3;
		var switchbleft = (document.body.clientWidth / 2) - 41;
		//		var width = 250;
		//上次的color指数
		var lastrgbcode;
		$('#colorPicker1').attr('width', width).attr('height', width);
		$('#rgbonoffbtn').css('margin-top', switchbttop).css('margin-left', switchbleft);
		var colorPicker = new colorPicker(document.getElementById('colorPicker1'), {
			h : 0.5,
			s : 5,
			v : 0,
			bgcolor : '#f0f0f0'
		});
		//设置控制手环的初始位置
		function setcirclesit(rgb_hues) {
			colorPicker.setColorHSV(rgb_hues, 5, 0);
		}

		function ctrlrgb() {
			rgbctrlinterval = self.setInterval("sendrgbcode()", 1 * 1000);
		}

		function sendrgbcode() {
			var color = colorPicker.getColorHSV();
			var colorcode = parseInt(color.h * 360);
			var brightcode = $('#brightspanid').val();
			var satcode = $('#satspanid').val();
			//			var rgbcode = '{"5":true,"6":' + colorcode + ',"7":' + satcode + ',"8":' + brightcode + '}';
			var rgbcode = '{"' + RGB_SWI_KEY + '":true,"' + RGB_HUES_KEY + '":' + colorcode + ',"' + RGB_SATU_KEY + '":' + satcode + ',"' + RGB_BRIGHT_KEY + '":' + brightcode + '}';
			if (lastrgbcode == rgbcode) {
				//没更新，不做处理
			} else {
				if ("../image/switchon.svg" == $("#rgbonoffbtn").attr("src")) {
					micoPublish(DEVID_GLOBAL + "/in/write/" + app1, rgbcode);
					lastrgbcode = rgbcode;
				}
			}
		}

		function sliderctrl() {
			//亮度
			bsliderMask = new Dragdealer('brightslider', {
				animationCallback : function(x, y) {
					$('#brightspanid').val(Math.round(x * 100));
				}
			});
			bsliderMask.setValue(rgb_bright, 0, true);
			//饱和度
			ssliderMask = new Dragdealer('satslider', {
				animationCallback : function(x, y) {
					$('#satspanid').val(Math.round(x * 100));
				}
			});
			ssliderMask.setValue(rgb_statu, 0, true);
		}
	</script>
</html>